package org.deltaset.desktop;

import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author dmakariev
 */
public class MenuItem implements Serializable, Permission {

    private final String title;
    private final String templateSrc;
    private final Map<String, String> parameters;
    private final boolean refreshable;
    private final String permission;

    public MenuItem(final MenuItem mi) {
        this(mi.refreshable, mi.title, mi.templateSrc, mi.permission, new HashMap<String, String>(mi.parameters));
    }

    public MenuItem(String title, String templateSrc, String permission) {
        this(false, title, templateSrc, permission, Collections.EMPTY_MAP);
    }

    public MenuItem(boolean refreshable, String title, String templateSrc, String permision, Map<String, String> parameters) {
        this.title = title;
        this.templateSrc = templateSrc;
        this.parameters = parameters;
        this.refreshable = refreshable;
        this.permission = permision;
    }

    public String getTitle() {
        return title;
    }

    public String getTemplateSrc() {
        return templateSrc;
    }

    public String getParameter(String name) {
        return parameters.get(name);
    }

    public Collection<String> getParameterNames() {
        return parameters.keySet();
    }

    boolean isRefreshable() {
        return refreshable;
    }

    @Override
    public String getPermission() {
        return permission;
    }
}
